#ifndef _PAGE_H
#define _PAGE_H

#include "draw.h"
#include "hanzi.h"
#include "draw.h"
#include <unistd.h>
#include "movie.h"

void init_homepage();
void init_musicpage();
void draw_music_play_gif();
void draw_music_play();
void draw_music_pause();

void draw_prev_xy();
void draw_next_xy();
void draw_music_back();
void init_moviepage(int *);

void init_gamepage();
void winnerpage(int *);

void init_gamepage()
{
    display_bmp("./bmp/game/bg1.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/game/1.bmp", 150, 10, 255, 255, 255);
    display_bmp("./bmp/game/back.bmp", 0, 0, 255, 255, 255);
}

void init_moviepage(int *play)
{
    display_bmp("./bmp/movie/bg.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/movie/back.bmp", 0, 0, 255, 255, 255);
    draw(play);
}


//display the UI of the game page 
void winnerpage(int *winner)
{
    if (*winner == 1)
    {
        // black piece win the game
        display_bmp("./bmp/game/blackwin.bmp", 140, 0, 255, 255, 255);
    }

    if (*winner == 2)
    {
        // white win
        display_bmp("./bmp/game/whitewin.bmp", 140, 0, 255, 255, 255);
    }
}

void init_homepage()
{
    display_bmp("./bmp/home/home.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/home/movie.bmp", 50, 140, 0, 0, 0);
    display_bmp("./bmp/home/game.bmp", 300, 140, 0, 0, 0);
    display_bmp("./bmp/home/music.bmp", 550, 140, 0, 0, 0);
    draw_home_page();
}

void init_musicpage()
{

    display_bmp("./bmp/music/music_bg.bmp", 0, 0, -1, -1, -1);

    display_bmp("./bmp/music/start.bmp", 500, 200, 255, 255, 255);
    display_bmp("./bmp/music/prev.bmp", 420, 220, 255, 255, 255);
    display_bmp("./bmp/music/next.bmp", 620, 220, 255, 255, 255);
    display_bmp("./bmp/music/back.bmp", 0, 0, 255, 255, 255);

    display_bmp("./bmp/music/1/1.bmp", 30, 50, 38, 38, 38);
}

void draw_music_play()
{

    display_bmp("./bmp/music/music_bg.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/music/start.bmp", 500, 200, 255, 255, 255);
    display_bmp("./bmp/music/prev.bmp", 420, 220, 255, 255, 255);
    display_bmp("./bmp/music/next.bmp", 620, 220, 255, 255, 255);
    display_bmp("./bmp/music/1/1.bmp", 30, 50, 38, 38, 38);
    display_bmp("./bmp/music/back.bmp", 0, 0, 255, 255, 255);
}

void draw_music_pause()
{
    display_bmp("./bmp/music/music_bg.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/music/pause.bmp", 500, 200, 255, 255, 255);
    display_bmp("./bmp/music/prev.bmp", 420, 220, 255, 255, 255);
    display_bmp("./bmp/music/next.bmp", 620, 220, 255, 255, 255);
    display_bmp("./bmp/music/1/1.bmp", 30, 50, 38, 38, 38);
    display_bmp("./bmp/music/back.bmp", 0, 0, 255, 255, 255);
}


// display the response if you click the prev songs
void draw_prev_xy()
{
    display_bmp("./bmp/music/prev_xy.bmp", 420, 220, 255, 255, 255);
    usleep(500000);

    display_bmp("./bmp/music/music_bg.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/music/start.bmp", 500, 200, 255, 255, 255);
    display_bmp("./bmp/music/prev.bmp", 420, 220, 255, 255, 255);
    display_bmp("./bmp/music/next.bmp", 620, 220, 255, 255, 255);
    display_bmp("./bmp/music/1/1.bmp", 30, 50, 38, 38, 38);
    display_bmp("./bmp/music/back.bmp", 0, 0, 255, 255, 255);
}

void draw_next_xy()
{
    display_bmp("./bmp/music/next_xy.bmp", 620, 220, 255, 255, 255);
    usleep(500000);

    display_bmp("./bmp/music/music_bg.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/music/pause.bmp", 500, 200, 255, 255, 255);
    display_bmp("./bmp/music/prev.bmp", 420, 220, 255, 255, 255);
    display_bmp("./bmp/music/next.bmp", 620, 220, 255, 255, 255);
    display_bmp("./bmp/music/1/1.bmp", 30, 50, 38, 38, 38);
    display_bmp("./bmp/music/back.bmp", 0, 0, 255, 255, 255);
}

void draw_music_back()
{

    display_bmp("./bmp/music/back_xy.bmp", 0, 0, 255, 255, 255);
    usleep(500000);
    display_bmp("./bmp/music/music_bg.bmp", 0, 0, -1, -1, -1);
    display_bmp("./bmp/music/pause.bmp", 500, 200, 255, 255, 255);
    display_bmp("./bmp/music/prev.bmp", 420, 220, 255, 255, 255);
    display_bmp("./bmp/music/next.bmp", 620, 220, 255, 255, 255);
    display_bmp("./bmp/music/1/1.bmp", 30, 50, 38, 38, 38);
    display_bmp("./bmp/music/back.bmp", 0, 0, 255, 255, 255);

    init_homepage();
}

#endif